package com.ruoyi.web.controller.smartHighway;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smartHighway.domain.RoadBreak;
import com.ruoyi.smartHighway.service.IRoadBreakService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 路面异常信息Controller
 * 
 * @author ljj
 * @date 2024-08-01
 */
@Api("路面异常信息")
@RestController
@RequestMapping("/smartHighway/roadBreak")
public class RoadBreakController extends BaseController {

    @Autowired
    private IRoadBreakService roadBreakService;

    /**
     * 查询路面异常信息列表
     */
    @ApiOperation("查询路面异常信息列表")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:list')")
    @GetMapping("/list")
    public TableDataInfo list(RoadBreak roadBreak) {
        startPage();
        List<RoadBreak> list = roadBreakService.selectRoadBreakList(roadBreak);
        return getDataTable(list);
    }

    /**
     * 导出路面异常信息列表
     */
    @ApiOperation("导出路面异常信息列表")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:export')")
    @Log(title = "路面异常信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RoadBreak roadBreak) {
        List<RoadBreak> list = roadBreakService.selectRoadBreakList(roadBreak);
        ExcelUtil<RoadBreak> util = new ExcelUtil<RoadBreak>(RoadBreak.class);
        util.exportExcel(response, list, "路面异常信息数据");
    }

    /**
     * 获取路面异常信息详细信息
     */
    @ApiOperation("获取路面异常信息详细信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:query')")
    @GetMapping(value = "/{breakId}")
    public AjaxResult getInfo(@PathVariable("breakId") Long breakId) {
        return success(roadBreakService.selectRoadBreakByBreakId(breakId));
    }

    /**
     * 新增路面异常信息
     */
    @ApiOperation("新增路面异常信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:add')")
    @Log(title = "路面异常信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RoadBreak roadBreak) {
        return toAjax(roadBreakService.insertRoadBreak(roadBreak));
    }

    /**
     * 修改路面异常信息
     */
    @ApiOperation("修改路面异常信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:edit')")
    @Log(title = "路面异常信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RoadBreak roadBreak) {
        return toAjax(roadBreakService.updateRoadBreak(roadBreak));
    }

    /**
     * 删除路面异常信息
     */
    @ApiOperation("删除路面异常信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:roadBreak:remove')")
    @Log(title = "路面异常信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{breakIds}")
    public AjaxResult remove(@PathVariable Long[] breakIds) {
        return toAjax(roadBreakService.deleteRoadBreakByBreakIds(breakIds));
    }
}
